<?php
    /**
     * Created by PhpStorm.
     * User: jackhhy
     * Date: 2019/6/26-15:38
     * Link: https://gitee.com/luckygyl/lucky_admin
     * FileName: SystemBase.php
     * Keys: ctrl+alt+L/ctrl+s(代码格式化) ctrl+J(代码提示) ctrl+R(替换)ALT+INSERT(生成代码(如GET,SET方法,构造函数等) , 光标在类中才生效)
     * CTRL+ALT+O (优化导入的类和包 需要配置) SHIFT+F2(高亮错误或警告快速定位错误)
     * CTRL+SHIFT+Z(代码向前) CTRL+SHIFT+/ (块状注释) ctrl+shift+enter(智能完善代码 如if())
     */

    namespace app\admin\controller;


    use app\common\controller\AdminBase;
    use service\CacheService;
    use service\JsonService;
    use think\Exception;
    use think\Session;

    class SystemBase extends AdminBase
    {

        protected static $admin_info;

        protected function _initialize()
        {
            parent::_initialize(); // TODO: Change the autogenerated stub
            //登录检测
            if(!Session::has('admin_info.username')) {
                $this->redirect('Login/index');
            }

            self::$admin_info = Session::get("admin_info");//
            $this->assign("admin_info", self::$admin_info);



        }




        /**
         * 成功提示一直持续
         * @param $msg
         * @param int $backUrl
         * @param string $title
         * @return mixed
         */
        protected function successfulNoticeLast($msg = '操作成功', $backUrl = 0, $info = '')
        {
            return $this->successfulNotice($msg, $backUrl, $info, 0);
        }

        /**
         * @param string $msg
         * @param int $url
         * @param $wait
         * @return mixed
         * @author: Jackhhy <jackhhy520@qq.com>
         * @name: failed
         * @describe:错误提醒页面
         */
        protected function failed($msg = '哎呀…亲…您访问的页面出现错误', $url = 0, $wait)
        {
            $this->assign(compact('msg', 'url', 'wait'));
            return $this->fetch('public/jump');
        }


        /**
         * @param string $msg
         * @return mixed
         * @author: Jackhhy
         * @name: exception
         * @describe:异常抛出
         */
        protected function exception($msg = '无法打开页面')
        {
            $this->assign(compact('msg'));
            return $this->fetch('public/500');
        }


        /**
         * @author: Jackhhy <jackhhy520@qq.com>
         * @name: false_to
         * @describe:系统演示
         */
        protected function false_to(){
            $this->error("系统演示，无操作权限");
        }



    }